<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/echars.js"></script>
    <script src="./js/jquery.min.js"></script>
    <style>
        * {
            margin: 0 auto;
            padding: 0;
        }
        .box {
            width: 400px;
            height: 400px;
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <script>
        $(function() {
            var myChart = echarts.init($('.box')[0]);
            myChart.setOption({
                legend: {
                    show: true,
                    // data: ['淘宝', '京东', '唯品会', '拼多多', '天猫'],
                },
                tooltip: {
                    trigger: 'item',
                    formatter: '{a} </br> {b} : {c} ({d}%)'
                },
                series: [{
                    type: 'pie',
                    radius: ['30%', '50%'],
                    data: [{
                        name: '淘宝',
                        value: 40,
                    },{
                        name: '京东',
                        value: 43,
                    }, {
                        name: '唯品会',
                        value: 54,
                    }, {
                        name: '拼多多',
                        value: 76,
                    }, {
                        name: '天猫',
                        value: 32,
                    }],
                    label: {
                        show:true,
                    }
                }],
            });
            myChart.on('click', () => {
                alert('别点我');
            })
            myChart.on('legendselectchanged', () =>{
                console.log('clicked legend');
            })
        })
    </script>
</body>
</html>